import request from '@/utils/request'

export function list(query) {
    return request({
        url: '/mallOrder/list',
        method: 'post',
        data: query
    })
}

export function info(id) {
    return request({
        url: '/mallOrder/info/' + id,
        method: 'get'
    })
}

export function save(data) {
    return request({
        url: '/mallOrder/save',
        method: 'post',
        data
    })
}

export function update(data) {
    return request({
        url: '/mallOrder/update',
        method: 'post',
        data
    })
}

export function remove(data) {
    return request({
        url: '/mallOrder/delete',
        method: 'post',
        data
    })
}

//获取明细
export function getItems(id) {
    let params = {id}
    return request.get('/mallOrder/items',{params})
}

//转货
export function transfer(param) {
    let url = '/mallOrder/transfer'
    let data = param
    return request.post(url,data)
}


export function downLoad() {
    let url = '/mallOrder/download'
    let config = {
        responseType: 'arraybuffer',
    }
    return request.post(url,null,config)
}

export function profit(query){
    let url = '/mallOrder/profit'
    let config = {
        responseType: 'arraybuffer',
    }
    return request.post(url,query,config)
}

export function account(query){
    let url = '/mallOrder/account'
    let config = {
        responseType: 'arraybuffer',
    }
    return request.post(url,query,config)
}

export function store(query){
    let url = '/mallOrder/store'
    let config = {
        responseType: 'arraybuffer',
    }
    return request.post(url,query,config)
}

export function sale(code,startDate,endDate){
    let url = '/mallOrder/sale'
    let config = {
        responseType: 'arraybuffer',
    }
    let data = {code,startDate,endDate}
    return request.post(url, data,config)
}

export function downLoads(query) {
    let url = '/mallOrder/downloadOrder'
    let config = {
        responseType: 'arraybuffer',
    }
    return request.post(url,query,config)
}

export function upload(file) {
    let url = '/mallOrder/upload';
    let forms = new FormData()
    forms.append("file",file)
    let config = {
        headers:{'Content-Type':'multipart/form-data'}
    }; //
    return request.post(url,forms,config)
}

//恢复订单
export function renew() {
    let url = '/mallOrder/renew'
    return request.post(url)
}

//取消订单
export function close(orderId) {
    let url = '/mallOrder/close'
    let data = {orderId}
    return request.post(url,data)
}

//支付订单
export function pay(orderId) {
    let url = '/mallOrder/pay'
    let data = {orderId}
    return request.post(url,data)
}
//提走订单
export function mention(orderId) {
    let url = '/mallOrder/mention'
    let data = {orderId}
    return request.post(url,data)
}
